package com.sumainfor.pc.gmio.controller;

import com.sumainfor.common.util.JsonResult;
import com.sumainfor.common.utlis.Pager;
import com.sumainfor.pc.gmio.feign.BasePcEpcFeign;
import com.sumainfor.pc.gmio.feign.BasePcMktFeign;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@Controller
@RequestMapping("/HousingController")
public class HousingController {

    Logger log = LoggerFactory.getLogger(HousingController.class);// 日志

    @Autowired
    BasePcMktFeign housingauditfeign;
    @Autowired
    BasePcEpcFeign basePcEpcFeign;
    /**
     *根据位置查询小区
     **/
    @ResponseBody
    @GetMapping("getComName")
    public JsonResult getComName(@RequestParam Map<String, Object> params){

        return  housingauditfeign.getComName(params);
    }

    /**
     *根据小区查询楼号
     **/
    @ResponseBody
    @GetMapping("getBuilding")
    public JsonResult getBuilding(@RequestParam Map<String, Object> params){

        return  housingauditfeign.getBuilding(params);
    }

    /**
     *根据小区查询楼号
     **/
    @ResponseBody
    @GetMapping("getRoom")
    public JsonResult getRoom(@RequestParam Map<String, Object> params){

        return  housingauditfeign.getRoom(params);
    }

    /**
     *根据小区查询楼号
     **/
    @ResponseBody
    @GetMapping("getplan_info_building")
    public JsonResult getplan_info_building(@RequestParam Map<String, Object> params,Pager pager){

        return  basePcEpcFeign.getplan_info_building(params,pager);
    }

    /**
     *根据小区查询楼号
     **/
    @ResponseBody
    @GetMapping("updateInspectStateBy")
    public JsonResult updateInspectStateBy(@RequestParam Map<String, Object> params){

        return  basePcEpcFeign.updateInspectStateBy(params);
    }

    /**
     *查询报修物品清单分类
     **/
    @ResponseBody
    @GetMapping("getArticleType")
    public JsonResult getArticleType(@RequestParam Map<String, Object> params){

        return  basePcEpcFeign.getArticleType(params);
    }

    /**
     *根据武平清单分类id 查询报修物品清单
     **/
    @ResponseBody
    @GetMapping("getarticle")
    public JsonResult getarticle(@RequestParam Map<String, Object> params){

        return  basePcEpcFeign.getarticle(params);
    }

    /**
     * 根据报修物品清单id 查询故障描述
     **/
    @ResponseBody
    @GetMapping("getArticleTrouble")
    public JsonResult getArticleTrouble(@RequestParam Map<String, Object> params){

        return  basePcEpcFeign.getArticleTrouble(params);
    }




    /**
     *新增新增厨房区域(管家验房的图片)
     **/
    @ResponseBody
    @PostMapping("saveHouingKitchenFile")
    public JsonResult saveHouingKitchenFile(@RequestBody Map<String, Object> params){

        return  housingauditfeign.saveHouingKitchenFile(params);
    }

    /**
     *查询厨房区域(管家验房的图片)
     **/
    @ResponseBody
    @RequestMapping("gethousingKitchenFileByid")
    public JsonResult gethousingKitchenFileByid(@RequestParam Map<String, Object> params){

        return  housingauditfeign.gethousingKitchenFileByid(params);
    }


    /**
     *新增新增卫生间区域(管家验房的图片)
     **/
    @ResponseBody
    @PostMapping("saveHouingToiletFile")
    public JsonResult saveHouingToiletFile(@RequestBody Map<String, Object> params){

        return  housingauditfeign.saveHouingToiletFile(params);
    }

    /**
     *查询卫生间区域(管家验房的图片)
     **/
    @ResponseBody
    @RequestMapping("gethousingToiletFileByid")
    public JsonResult gethousingToiletFileByid(@RequestParam Map<String, Object> params){

        return  housingauditfeign.gethousingToiletFileByid(params);
    }



    /**
     *新增新增卫生间区域(管家验房的图片)
     **/
    @ResponseBody
    @PostMapping("saveHouingDiningFile")
    public JsonResult saveHouingDiningFile(@RequestBody Map<String, Object> params){

        return  housingauditfeign.saveHouingDiningFile(params);
    }



    /**
     *新增新房源主图片(管家验房的图片)
     **/
    @ResponseBody
    @PostMapping("saveHouingHouseImg")
    public JsonResult saveHouingHouseImg(@RequestBody Map<String, Object> params){

        return  housingauditfeign.saveHouingHouseImg(params);
    }




    /**
     *新增新房源主图片(管家验房的图片)
     **/
    @ResponseBody
    @PostMapping("saveHouingShowImg")
    public JsonResult saveHouingShowImg(@RequestBody Map<String, Object> params){

        return  housingauditfeign.saveHouingShowImg(params);
    }



    /**
     *查询卫生间区域(管家验房的图片)
     **/
    @ResponseBody
    @RequestMapping("gethousingDiningFileByid")
    public JsonResult gethousingDiningFileByid(@RequestParam Map<String, Object> params){

        return  housingauditfeign.gethousingDiningFileByid(params);
    }


    /**
     *查询卫生间区域(管家验房的图片)
     **/
    @ResponseBody
    @RequestMapping("gethousingShowImgByid")
    public JsonResult gethousingShowImgByid(@RequestParam Map<String, Object> params){

        return  housingauditfeign.gethousingShowImgByid(params);
    }


    /**
     *查询卫生间区域(管家验房的图片)
     **/
    @ResponseBody
    @RequestMapping("gethousingHouseImgByid")
    public JsonResult gethousingHouseImgByid(@RequestParam Map<String, Object> params){

        return  housingauditfeign.gethousingHouseImgByid(params);
    }



    /**
     *查询房间(管家验房的图片)
     **/
    @ResponseBody
    @RequestMapping("getHousingConInfo")
    public JsonResult getHousingConInfo(@RequestParam Map<String, Object> params){

        return  housingauditfeign.getHousingConInfo(params);
    }

    /**
     *新增房间区域(管家验房的图片)
     **/
    @ResponseBody
    @PostMapping("saveHouingInfoFile")
    public JsonResult saveHouingInfoFile(@RequestBody Map<String, Object> params){

        return  housingauditfeign.saveHouingInfoFile(params);
    }

    /**
     *图片上传完了之后 点击完成验房图片上传
     **/
    @ResponseBody
    @RequestMapping("updateUpload")
    public JsonResult updateUpload(@RequestParam Map<String, Object> params){
        JsonResult result1  = new JsonResult();

        JsonResult result = housingauditfeign.getocuntHouging(params);//首先接受了这个值

        Map<String,Object> map =(Map<String,Object>) result.get("result");

        log.info("result======>"+result);

        log.info("map======>"+map);

        if("1".equals(map.get("housingcon").toString()) && "0".equals(map.get("infocon").toString())){
            //标识图片都是上传成功的

            JsonResult res= basePcEpcFeign.updateIfUpload(params);

            log.info("res======>"+res);
            if("0".equals(res.get("errorCode").toString())){

                housingauditfeign.updateAccepted(params);

                result1.putSuccess("操作成功");
            }else {

                result1.putFailed("操作失败");
            }


        }else{

            result1.putFailed("请完善图片上传");
        }
        return  result1;
    }

    @ResponseBody
    @PostMapping("saveTepair")
    public JsonResult saveTepair(@RequestBody Map<String, Object> params){

        return  basePcEpcFeign.saveTepair(params);
    }

    @ResponseBody
    @RequestMapping("gethousingByState")
    public JsonResult gethousingByState(@RequestParam Map<String, Object> params){

        return  housingauditfeign.gethousingByState(params);
    }

}
